package main.整数反转;

public class Solution {

    public static void main(String[] args) {

        double pow = Math.pow(2, 31);
        int data = (int) pow;
        System.out.println(pow);
        //2,147,483,648
        System.out.println(data-1);

    }

    public int reverse(int x) {
        boolean fu = false;
        if(x < 0){
            fu = true;
        }

        StringBuilder stringBuilder = new StringBuilder(String.valueOf(x));

        if(fu){
            stringBuilder = new StringBuilder(stringBuilder.substring(1));
        }

        try {
            int result = Integer.parseInt(stringBuilder.reverse().toString());
            if(fu){
                return result * (-1);
            }
            else{
                return result;
            }
        }catch (Exception e){
            return 0;
        }
    }
}
